package com.deep.deepenterprise.api.config;

import com.deep.deepenterprise.api.interceptor.DrAccessInterceptor;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;


/**
 * @author xyz
 * @description 全局拦截器 用于拦截注解
 * @time 2024/4/16 11:34
 */
@Configuration
@AllArgsConstructor
public class DrInterceptorConfig implements WebMvcConfigurer {

    private final DrAccessInterceptor drAccessInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 拦截所有请求
        final List<String> paths = new ArrayList<>();
        paths.add("/v12/interface/dr/dr-car-order-list");
        registry.addInterceptor(drAccessInterceptor).addPathPatterns("/v12/**").excludePathPatterns(paths);
    }
}
